
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id'=>'searchForm',
    'type'=>'search',
    'htmlOptions'=>array('class'=>'well'),
)); ?>
<?php echo $form->textFieldRow($model, 'activity_name', array('class'=>'input-xlarge', 'prepend'=>'<i class="icon-search"></i>')); ?>

<?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'label'=>'搜索')); ?>
 
<?php $this->endWidget(); ?>

<?php $form=$this->beginWidget('CActiveForm', array(
        'enableAjaxValidation'=>true,
    )); ?>

<script>
function reloadGrid(data) {
    $.fn.yiiGridView.update('activity-grid');
}
</script>
<div class="btn-toolbar">

<?php $this->widget('bootstrap.widgets.TbButton', array(
    'type'=>'danger',
    'buttonType'=>'ajaxSubmit',
    'size'=>'small',
    'icon'=>'remove white',
    'label'=>'删除', 
    'url'=>array('activity/ajaxDelete'), 
    'ajaxOptions'=>array(
        'success'   =>  'reloadGrid',
    ),
    'htmlOptions'=>array(
        'confirm'=>'确认要删除吗?',
    ),

)); ?>

<?php $this->widget('bootstrap.widgets.TbButton', array(
    'type'=>'primary',
    'label'=>'新建活动',
    'icon'=>'plus white',
    'url'=>array('activity/create', 'type' => $_GET['type']),
    'size'=>'small',
     
)); ?>
</div>

<?php $this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'activity-grid',
    'type'=>'striped bordered condensed',
    'dataProvider'  =>  $dataProvider,
    'pager'=>array(
        'class'=>'CLinkPager',           
        'nextPageLabel'=>'下一页>',           
        'prevPageLabel'=>'<上一页',           
        'header'=>'',   
    ),   
    'selectableRows'=> 2,
    'template'      =>  '{items}{pager}',
    'columns'       =>  array(
       array(
            'id'    =>  'autoId',
            'class' =>  'CCheckBoxColumn',
        ),
        array(
            'header'=>  '#',
            'name'  =>  'activity_id',
            'value' =>  '$data->activity_id'
        ),
       array(
            'name'  =>  'activity_name',
			'type'  =>  'raw',
        	'value' =>  'CHtml::link(CHtml::encode($data->activity_name), Yii::app()->controller->createUrl("activity/update", array("id"=>$data->activity_id, "type"=>$data->activity_type)))'
        ),
        array(
            'name'  =>  'activity_type',
            'value' =>  'ActivityType::$names[$data->activity_type]',
        ),
        array(
            'name'  =>  'programs',
            'value' =>  '$data->programs'
        ),
        /*
        array(
            'name'  =>  'inputs',
            'value' =>  '$data->inputs'
        ), 
        array(
            'name'  =>  'outputs',
            'value' =>  '$data->outputs'
        ),
        array(
            'name'  =>  'params',
            'value' =>  '$data->params'
        ),
         */
        array(
            'class' =>  'bootstrap.widgets.TbButtonColumn',
             'template'=>'{delete}',           
             'buttons'=>array(
                'delete'   =>  array(
                    'label'     =>  '删除活动',
                     'url'      =>  'Yii::app()->controller->createUrl("activity/delete", array("id"=>$data->activity_id))',
                    ),
                ),
        ),
    ),
));
?>
<?php $this->endWidget(); ?>
